﻿
@{
    ViewData["Title"] = "添加热门文章链接";
}

<div class="row">
    <form id="ajaxForm" enctype="multipart/form-data" class="form-horizontal">
        <div class="container-fluid">
            <div class="row form-group">
                <label class="control-label col-md-2">标题</label>
                <div class="col-md-10">
                    <input class="form-control" name="title" id="title" type="text" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">url链接</label>
                <div class="col-md-10">
                    <input class="form-control" name="url" id="url" type="text" placeholder="绝对路径,或者相对路径" />
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">排序数字</label>
                <div class="col-md-10">
                    <input class="form-control" name="sort_num" id="sort_num" type="number" max="100" min="1" value="100"/>
                </div>
            </div>
            <div class="row form-group">
                <label class="control-label col-md-2">是否显示</label>
                <div class="col-md-10">
                    <input class="i-checks" name="is_show" id="is_show" type="checkbox" value="true"/>
                </div>
            </div>

            <div class="row form-group">
                <div class="col-md-6 col-md-offset-2">
                    <button type="button" class="btn btn-primary" onclick="SaveArticleUrl()">保存</button>
                </div>
            </div>
        </div>
    </form>
</div>

@section scripts{
    <script type="text/javascript">

        function SaveArticleUrl() {
            if ($("#title").val().length == 0) {
                utils.ShowError("请输入标题");
                return;
            }
            if ($("#url").val().length == 0) {
                utils.ShowError("请输入链接");
                return;
            }

            $("#ajaxForm").ajaxSubmit({
                type: 'post',
                url: '@Url.Action("Save")',
                data: {
                    
                },  // data是作为额外提交的表单数据
                success: function (e) {
                    if (e.msg == 'ok') {
                        utils.ShowSuccess(e.data, function () {
                            location.href = '@Url.Action("article")';
                        });
                    }
                },
                error: function (e) {
                    utils.ShowError(e.data);
                }
            });
        }
    </script>
}

